<html>
<head>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

var submissionCount = 0;
var disallowedSubmission = false;

function allowedFormSubmitted()
{
    ++submissionCount;

    if (submissionCount == 2) {
        document.getElementById("test_status").innerHTML = (disallowedSubmission ? "FAIL" : "PASS");

        if (window.testRunner)
            testRunner.notifyDone();
    }
}

function disallowedFormSubmitted()
{
    disallowedSubmission = true;
}

window.onload = function() {
    frameElements = document.getElementsByTagName("iframe");

    frameElements[0].sandbox = "allow-scripts allow-same-origin";
    frameElements[1].sandbox = "allow-scripts allow-forms allow-same-origin";
    frameElements[2].sandbox = "allow-scripts allow-same-origin";

    frames[0].postMessage("go", "*");
    frames[1].postMessage("go", "*");
    frames[2].postMessage("go", "*");
}

</script>
</head>

<body>

    <iframe style="width: 60px; height: 60px;"
        sandbox="allow-scripts allow-forms allow-same-origin"
        src="resources/sandboxed-iframe-form-dynamic-allowed.html">
    </iframe>
    <iframe style="width: 60px; height: 60px;"
        sandbox="allow-scripts allow-same-origin"
        src="resources/sandboxed-iframe-form-dynamic-disallowed.html">
    </iframe>
    <iframe style="width: 60px; height: 60px;"
        sandbox="allow-scripts allow-forms allow-same-origin"
        src="resources/sandboxed-iframe-form-dynamic-allowed.html">
    </iframe>

    <p id='test_status'>FAIL: Script didn't run</p>
</body>
</html>
